home *** CD-ROM | disk | FTP | other *** search
- import java.awt.Color;
- import java.awt.Event;
- import java.awt.Graphics;
- import java.awt.Point;
- import java.awt.Toolkit;
- import java.io.DataInputStream;
- import java.util.NoSuchElementException;
-
- public class CCheckButtonResponse extends CDisplayResponse {
- public static final int SPACING = 5;
- private CFontObject m_Font = new CFontObject();
- private String m_strText;
- private short m_cPrefixChar;
- private int m_nFlags;
- private Color m_rgbFg = new Color(0, 0, 0);
- private Color m_rgbBg = new Color(0, 0, 0);
- private String m_strSetExpression;
- private short m_wState = 0;
- private String m_strVarText = "";
- private CRect m_rcSymbol = new CRect();
-
- boolean LoadFromFile(DataInputStream var1) {
- this.m_Font.LoadFromFile(var1);
- this.m_strText = FileLoad.ReadCString(var1);
- this.m_strSetExpression = FileLoad.ReadCString(var1);
- this.m_cPrefixChar = FileLoad.ReadCPlusByte(var1);
- this.m_nFlags = FileLoad.ReadCPlusInt(var1);
- this.m_rgbFg = FileLoad.ReadColor(var1);
- this.m_rgbBg = FileLoad.ReadColor(var1);
- return super.LoadFromFile(var1);
- }
-
- public short GetAnswer() {
- byte var1 = 2;
- if ((this.m_wState & 16) != 0 && super.m_cLogType == 1 || (this.m_wState & 16) == 0 && super.m_cLogType == 2) {
- var1 = 1;
- }
-
- return (short)var1;
- }
-
- public CCheckButtonResponse() {
- super(25);
- }
-
- public void DoEntryResponse() {
- this.DoResponse(0);
- }
-
- private void ResetRadioButtonGroup() {
- CDrawObj var1 = null;
- Object var2 = null;
- CCheckButtonResponse var3 = null;
- boolean var4 = false;
- synchronized(Globals.thePresView.m_DrawObjectList){}
-
- try {
- try {
- var1 = Globals.thePresView.m_DrawObjectList.GetHead();
- } catch (NoSuchElementException var13) {
- var4 = true;
- }
-
- while(!var4) {
- if (var1 != null) {
- if (var1.GetIconObject().GetTypeID() == 25) {
- CCheckButtonResponse var15 = (CCheckButtonResponse)var1.GetIconObject();
- if ((var15.GetFlags() & 128) != 0) {
- if ((var15.GetFlags() & 32) != 0) {
- var3 = null;
- }
-
- if (Utils.StateTest(var15.GetState(), 16)) {
- var3 = var15;
- }
- }
- }
-
- if (var1.GetIconObject().equals(this)) {
- break;
- }
- }
-
- try {
- var1 = Globals.thePresView.m_DrawObjectList.GetNext();
- } catch (NoSuchElementException var12) {
- var4 = true;
- }
- }
-
- while(!var4 && var3 == null) {
- try {
- var1 = Globals.thePresView.m_DrawObjectList.GetNext();
- } catch (NoSuchElementException var11) {
- var4 = true;
- }
-
- if (var1 != null && !var4 && var1.GetIconObject().GetTypeID() == 25) {
- CCheckButtonResponse var16 = (CCheckButtonResponse)var1.GetIconObject();
- if ((var16.GetFlags() & 128) != 0) {
- if ((var16.GetFlags() & 32) != 0) {
- break;
- }
-
- if (Utils.StateTest(var16.GetState(), 16)) {
- var3 = var16;
- }
- }
- }
- }
- } catch (Throwable var14) {
- throw var14;
- }
-
- if (var3 != null && !var4) {
- var3.SetState((short)Utils.StateClear(var3.GetState(), 16));
- Globals.thePresView.Render(var3.m_rcSymbol);
- Globals.thePresView.Draw((Graphics)null, var3.m_rcSymbol);
- }
-
- }
-
- private void ToggleState() {
- if (Utils.StateTest(this.m_wState, 16)) {
- this.m_wState = (short)Utils.StateClear(this.m_wState, 16);
- } else {
- this.m_wState = (short)Utils.StateSet(this.m_wState, 16);
- }
-
- Globals.thePresView.Render(this.m_rcSymbol);
- Globals.thePresView.Draw((Graphics)null, this.m_rcSymbol);
- }
-
- public void SetState(short var1) {
- this.m_wState = var1;
- }
-
- public int GetFlags() {
- return this.m_nFlags;
- }
-
- public boolean OnKeyPress(int var1, Event var2) {
- if (this.m_cPrefixChar != 0 && var1 == Character.toUpperCase((char)this.m_cPrefixChar)) {
- this.ToggleState();
- }
-
- return false;
- }
-
- public CResponseReturn DoResponse(int var1) {
- CResponseReturn var2 = new CResponseReturn(0, var1);
- if (Utils.StateTest(this.m_wState, 16) && super.m_strVariableString.length() > 0) {
- Utils.SetVariables(super.m_strVariableString, false);
- }
-
- return var2;
- }
-
- public short GetState() {
- return this.m_wState;
- }
-
- public boolean OnMouseClick(int var1, int var2, Point var3, int var4, CRect var5) {
- if (var4 == 7) {
- if (((CDisplayResponse)this).HitTest(var3) && var1 == 2022 && !Utils.StateTest(this.m_wState, 8)) {
- this.m_wState = (short)Utils.StateSet(this.m_wState, 8);
- Globals.thePresView.Render(this.m_rcSymbol);
- Globals.thePresView.Draw((Graphics)null, this.m_rcSymbol);
- } else if (var1 == 2023 && Utils.StateTest(this.m_wState, 8)) {
- this.m_wState = (short)Utils.StateClear(this.m_wState, 8);
- if (Utils.StateTest(this.m_wState, 4)) {
- this.m_wState = (short)Utils.StateClear(this.m_wState, 4);
- } else if ((this.m_nFlags & 128) == 0 || Utils.StateTest(this.m_wState, 16) && !Utils.StateTest(this.m_wState, 16)) {
- if ((this.m_nFlags & 64) != 0) {
- this.ToggleState();
- }
- } else {
- this.ResetRadioButtonGroup();
- this.m_wState = (short)Utils.StateSet(this.m_wState, 16);
- Globals.thePresView.Render(this.m_rcSymbol);
- Globals.thePresView.Draw((Graphics)null, this.m_rcSymbol);
- }
- }
- }
-
- return false;
- }
-
- public boolean SetResponse() {
- if (!((CDisplayResponse)this).GetActualRect().isEmpty()) {
- boolean var1 = false;
- String var2 = Utils.InsertVariablesInString(this.m_strText);
- if (!var2.equals(this.m_strVarText)) {
- this.m_strVarText = var2;
- var1 = true;
- }
-
- if ((this.m_nFlags & 8) != 0 && !Utils.StateTest(this.m_wState, 16)) {
- if ((this.m_nFlags & 128) != 0) {
- this.ResetRadioButtonGroup();
- }
-
- this.m_wState = 16;
- var1 = true;
- } else if (this.m_strSetExpression.length() > 0) {
- if (Utils.CheckExpression(this.m_strSetExpression, false)) {
- if (!Utils.StateTest(this.m_wState, 16)) {
- if ((this.m_nFlags & 128) != 0) {
- this.ResetRadioButtonGroup();
- }
-
- this.m_wState = 16;
- var1 = true;
- }
- } else if (Utils.StateTest(this.m_wState, 16)) {
- this.m_wState = (short)Utils.StateClear(this.m_wState, 16);
- var1 = true;
- }
- }
-
- if (!((CDisplayResponse)this).GetActualRect().equals(((CDisplayResponse)this).GetDrawRect())) {
- if (!((CDisplayResponse)this).GetDrawRect().isEmpty()) {
- Globals.thePresView.InvalidateOffScreenRect(((CDisplayResponse)this).GetDrawRect());
- }
-
- ((CDisplayResponse)this).SetDrawRect(((CDisplayResponse)this).GetActualRect());
- var1 = true;
- }
-
- Globals.thePresView.AddDrawObject((CIconObject)this, 1024, var1);
- }
-
- return true;
- }
-
- public boolean OnMouseMove(int var1, Point var2, int var3, CRect var4) {
- if (var3 == 7 && Utils.StateTest(this.m_wState, 8)) {
- if (((CDisplayResponse)this).HitTest(var2) && Utils.StateTest(this.m_wState, 4)) {
- this.m_wState = (short)Utils.StateClear(this.m_wState, 4);
- Globals.thePresView.Render(this.m_rcSymbol);
- Globals.thePresView.Draw((Graphics)null, this.m_rcSymbol);
- } else if (!((CDisplayResponse)this).HitTest(var2) && !Utils.StateTest(this.m_wState, 4)) {
- this.m_wState = (short)Utils.StateSet(this.m_wState, 4);
- Globals.thePresView.Render(this.m_rcSymbol);
- Globals.thePresView.Draw((Graphics)null, this.m_rcSymbol);
- }
- }
-
- return false;
- }
-
- public void DrawObject(Graphics var1, int var2, CRect var3) {
- Graphics var4 = var1.create();
- var4.clipRect(var3.x, var3.y, var3.width, var3.height);
- this.m_rcSymbol.width = this.m_rcSymbol.height = Math.min(Toolkit.getDefaultToolkit().getFontMetrics(this.m_Font.GetFont()).getHeight(), var3.height);
- this.m_rcSymbol.y = var3.y + (var3.height - this.m_rcSymbol.height) / 2;
- CRect var5 = new CRect();
- var4.setFont(this.m_Font.GetFont());
- var5.height = var3.height;
- var5.width = Math.max(var3.width - this.m_rcSymbol.width - 5, 0);
- var5.height = Math.min(Utils.DrawText(var4, this.m_strVarText, var5, 33).height, var3.height);
- var5.y = var3.y + (var3.height - var5.height) / 2;
- if ((this.m_nFlags & 1) != 0) {
- this.m_rcSymbol.x = var3.x + var5.width + 5;
- var5.x = var3.x;
- } else {
- this.m_rcSymbol.x = var3.x;
- var5.x = var3.x + this.m_rcSymbol.width + 5;
- }
-
- if ((this.m_nFlags & 16) != 0) {
- var4.setColor(this.m_rgbBg);
- var4.fillRect(var3.x, var3.y, var3.width, var3.height);
- }
-
- var4.setColor(this.m_rgbFg);
- if (this.m_strVarText.length() > 0) {
- Utils.DrawText(var4, this.m_strVarText, var5, 1);
- }
-
- if ((this.m_nFlags & 128) != 0) {
- var4.drawOval(this.m_rcSymbol.x, this.m_rcSymbol.y, this.m_rcSymbol.width, this.m_rcSymbol.height);
- if (Utils.StateTest(this.m_wState, 8) && !Utils.StateTest(this.m_wState, 4)) {
- var4.drawOval(this.m_rcSymbol.x + 1, this.m_rcSymbol.y + 1, this.m_rcSymbol.width - 2, this.m_rcSymbol.height - 2);
- }
-
- if (Utils.StateTest(this.m_wState, 16)) {
- var4.fillOval(this.m_rcSymbol.x + 3, this.m_rcSymbol.y + 3, this.m_rcSymbol.width - 5, this.m_rcSymbol.height - 5);
- return;
- }
- } else if ((this.m_nFlags & 64) != 0) {
- var4.drawRect(this.m_rcSymbol.x, this.m_rcSymbol.y, this.m_rcSymbol.width, this.m_rcSymbol.height);
- if (Utils.StateTest(this.m_wState, 8) && !Utils.StateTest(this.m_wState, 4)) {
- var4.drawRect(this.m_rcSymbol.x + 1, this.m_rcSymbol.y + 1, this.m_rcSymbol.width - 2, this.m_rcSymbol.height - 2);
- }
-
- if (Utils.StateTest(this.m_wState, 16)) {
- var4.drawLine(this.m_rcSymbol.x + 3, this.m_rcSymbol.y + 3, this.m_rcSymbol.x + this.m_rcSymbol.width - 3, this.m_rcSymbol.y + this.m_rcSymbol.height - 3);
- var4.drawLine(this.m_rcSymbol.x + 3, this.m_rcSymbol.y + this.m_rcSymbol.height - 3, this.m_rcSymbol.x + this.m_rcSymbol.width - 3, this.m_rcSymbol.y + 3);
- }
- }
-
- }
- }
-